package com.yue.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/8/1<br/>
 *
 * @author QiuYang
 */
@WebServlet(name = "first", urlPatterns = "/first")
public class MyFirstServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        try{
            out.println("<html>");
            out.println("<head>");
            out.println("<title> My First Servlet</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h2> Servlet My First Servlet at" + req.getContextPath() + "</h2>");
            out.println("</body>");
            out.println("</html>");
        }finally {
            out.close();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }

    @Override
    public String getServletInfo() {
        return "My first Servlet!";
    }
}
